<?php
/**
 * Created by PhpStorm.
 * User: verystar
 * Date: 2017/12/21
 * Time: 下午5:41
 */

class Json
{
    private $content;
    private $data;

    public function __construct()
    {
        $this->content = stream_get_contents(STDIN);
        $this->data = json_decode($this->content, true);
    }

    public function index($path = '')
    {
        if ($path == '') {
            return $this->data;
        }
        $arr = explode('.', $path);
        $last = $this->data;
        foreach ($arr as $item) {
            $last = $last[$item];
        }
        return $last;
    }
}